/**
 * This file is a part of qloudgen-sec. 
 * You can redistribute qloudgen-sec and/or modify it under the terms of the Lesser GNU General Public License version 3. 
 * qloudgen-sec is distributed WITHOUT ANY WARRANTY. 
 *
 * See the Lesser GNU General Public License for more details at http://www.gnu.org/licenses/. 
 **/
package org.qloudgen.sec.cas.client.proxy;

import java.io.Serializable;

/**
 * <p>Title: Cas client proxy granting ticket Implementation</p>
 * <p>Description: Wrappered proxy ticket value.</p>
 * <p>Copyright: qloudgen/sec 2014</p>
 * @author <a href="mailto:hyq.dd.sun@gmail.com">glue.3M</a>
 */
public final class CasProxyGrantingTicketHolder implements Serializable {
	/**
	 *
	 */
	private final String proxyGrantingTicket;
	/**
	 *
	 */
	private final long timeInserted;
	
	/**
	 * Custom constructor.
	 *
	 * @param proxyGrantingTicket
	 */
    public CasProxyGrantingTicketHolder(final String proxyGrantingTicket) {
		this.proxyGrantingTicket = proxyGrantingTicket;
		this.timeInserted = System.currentTimeMillis();
	}
	
	/**
	 *
	 *
	 * @return String
	 */
    public String getProxyGrantingTicket() {
		return proxyGrantingTicket;
	}
	
	/**
	 *
	 *
	 * @return boolean
	 */
    public boolean isExpired(final long cacheTimeout) {
		return ( ( System.currentTimeMillis() - this.timeInserted ) > cacheTimeout );
	}
}